<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>超市零售系统</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" th:href="@{/vendor/bootstrap/css/bootstrap.min.css}">
    <link th:href="@{/vendor/fonts/circular-std/style.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/libs/css/style.css}">
    <link rel="stylesheet" th:href="@{/vendor/fonts/fontawesome/css/fontawesome-all.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/dataTables.bootstrap4.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/buttons.bootstrap4.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/select.bootstrap4.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/vendor/datatables/css/fixedHeader.bootstrap4.css}">
    <style type="text/css">
        #container {
            overflow: hidden;
        }

        /* 清除浮bai动 */
        /*#container div{width:200px;height:100px;}*/
        .box1 {
            float: left;
        }

        .box2 {
            float: right;
            margin-right: 20px;
        }
    </style>
</head>

<body>

<!-- main wrapper -->
<div class="dashboard-main-wrapper">
    <!-- navbar::头部导航栏 -->
    <div class="dashboard-header">
        <div th:insert="~{commons/commons::topBar}"></div>
    </div>
    <!-- left sidebar -->
    <div class="nav-left-sidebar sidebar-dark">
        <div class="menu-list">
            <div th:insert="~{commons/commons::sideBar}"></div>
        </div>
    </div>
    <!-- wrapper  -->
    <div class="dashboard-wrapper">
        <div class="container-fluid  dashboard-content">
            <h2 class="pageheader-title">财务报表</h2>
            <!-- 总盈亏  -->
            <div class="row">
                <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                    <div class="card border-3 border-top border-top-primary">
                        <div class="card-body">
                            <h5 class="text-muted ">总盈亏</h5>
                            <div class="metric-value d-inline-block">
                                <h1 class="mb-1" th:text="${profits}"></h1>
                            </div>
                            <div class="metric-label d-inline-block float-right text-success font-weight-bold">
                                <span class="ml-1">元</span>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 总销量  -->
                <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                    <div class="card border-3 border-top border-top-primary">
                        <div class="card-body">
                            <h5 class="text-muted">毛利润</h5>
                            <div class="metric-value d-inline-block">
                                <h1 class="mb-1" th:text="${sales_moneys}"></h1>
                            </div>
                            <div class="metric-label d-inline-block float-right text-success font-weight-bold">
                                <span class="ml-1">元</span>
                            </div>
                        </div>
                    </div>
                </div>



                <!-- 报废量  -->

                <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                    <div class="card border-3 border-top border-top-primary">
                        <div class="card-body">
                            <h5 class="text-muted">报废损失</h5>
                            <div class="metric-value d-inline-block">
                                <h1 class="mb-1" th:text="${scrap_moneys}"></h1>
                            </div>
                            <div class="metric-label d-inline-block float-right text-success font-weight-bold">
                                <span class="ml-1">元</span>
                            </div>
                        </div>
                    </div>
                </div>


                <!-- 总成本  -->

                <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 col-12">
                    <div class="card border-3 border-top border-top-primary">
                        <div class="card-body">
                            <h5 class="text-muted">已售物品成本</h5>
                            <div class="metric-value d-inline-block">
                                <h1 class="mb-1" th:text="${costs}"></h1>
                            </div>
                            <div class="metric-label d-inline-block float-right text-success font-weight-bold">
                                <span class="ml-1">元</span>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- end total orders  -->

            </div>
            <div class="row">
                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="page-header">
                        <p class="pageheader-text">Proin placerat ante duiullam scelerisque a velit ac porta, fusce sit
                            amet vestibulum mi. Morbi lobortis pulvinar quam.</p>
                        <div class="page-breadcrumb">
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                </ol>
                            </nav>
                        </div>
                    </div>
                </div>
            </div>

            <!--            模糊查询-->
            <!--            <form th:action="@{/statistics/queryAllBySomething}" method="post">-->
            <!--                <tr><td align="right">商品编号：</td><td><input type="text" name="proId"></td>-->
            <!--                    <td align="right">商品名称：</td><td><input type="text" name="proName"></td>-->
            <!--                    <td align="right">商品类别：</td><td><input type="text" name="proClass"></td>-->
            <!--                    <input type="submit" class="btn-primary" value="GO" />-->
            <!--                </tr>-->
            <!--            </form>-->
            <br>
            <div class="row">
                <!-- basic table  -->
                <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                    <div class="card">
                        <br>
                        <div>
                            <div class="box1"><h2 class="card-header">统计表</h2></div>

                            <div class="box2"><a class="btn btn-large btn-block btn-success"
                                                 th:href="@{/statistics/queryAll}">查看详情</a></div>
                        </div>
                        <br>
                        <div class="card-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered first text-center" id="productTable">
                                    <thead>
                                    <tr>
                                        <th>商品类别</th>
                                        <th>类别销售量&nbsp;&nbsp;&nbsp;
                                        </th>
                                        <th>类别总盈亏&nbsp;&nbsp;&nbsp;
                                        </th>
                                    </tr>
                                    <tbody>
                                    <tr th:each="product : ${allProductTypes}">
                                        <td th:text="${product.getProduct_class()}"></td>
                                        <td th:text="${product.getProduct_sold()}"></td>
                                        <td th:text="${product.getProduct_profit()}"></td>
                                    </tr>
                                    </tbody>
                                </table>
                                <br>
                                <br>

                            </div>
                        </div>
                    </div>
                </div>

                <!-- end basic table  -->

            </div>
        </div>


    </div>
    <!-- end footer -->
    <div class="footer">
        <div class="container-fluid">
            <div th:insert="~{commons/commons::footer}"></div>
        </div>
    </div>
</div>




<script th:src="@{/vendor/jquery/jquery-3.3.1.min.js}"></script>
<script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.js}"></script>
<script th:src="@{/vendor/slimscroll/jquery.slimscroll.js}"></script>
<script th:src="@{/vendor/multi-select/js/jquery.multi-select.js}"></script>
<script th:src="@{/libs/js/main-js.js}"></script>

<script th:src="@{/vendor/datatables/js/dataTables.bootstrap4.min.js}"></script>
<script th:src="@{/vendor/datatables/js/buttons.bootstrap4.min.js}"></script>
<script th:src="@{/vendor/datatables/js/data-table.js}"></script>

<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
    function searchSoldDown() {
        $.ajax({
            url: "/statistics/orderBySoldDown",
            success: function (data) {
                console.log(data);
                $("#productTable tbody").empty();
                $(data).each(function (index, item) {
                    $("#productTable tbody").append(" <tr>\n" +
                        "                                        <td>" + item.product_id + "</td>\n" +
                        "                                        <td>" + item.product_name + "</td>\n" +
                        "                                        <td>" + item.product_class + "</td>\n" +
                        "                                        <td>" + item.product_sold + "</td>\n" +
                        "                                        <td>" + item.product_scrap + "</td>\n" +
                        "                                        <td>" + item.product_profit + "</td>\n" +
                        "<tr/>"
                    );
                })
            }
        })
    }
</script>
</body>

</html>
